local skel = fk.CreateSkill {
  name = "emo__weikui",
  tags = {Skill.Compulsory, Skill.Switch},
}

Fk:loadTranslationTable{
  ["emo__weikui"] = "危溃",
  [":emo__weikui"] = "锁定技，转换技，阳：当你使用黑色牌时，失去1点体力并获得两张红色牌；阴：当你使用红色牌时，扣减1点体力上限并获得两张黑色牌。",

  [":emo__weikui_yang"] = "锁定技，转换技，<font color=\"#E0DB2F\">阳：当你使用黑色牌时，失去1点体力并获得两张红色牌；</font>阴：当你使用红色牌时，扣减1点体力上限并获得两张黑色牌。",
  [":emo__weikui_yin"] = "锁定技，转换技，阳：当你使用黑色牌时，失去1点体力并获得两张红色牌；<font color=\"#E0DB2F\">阴：当你使用红色牌时，扣减1点体力上限并获得两张黑色牌。</font>",
}

skel:addEffect(fk.CardUsing, {
  anim_type = "switch",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(skel.name) then
      if player:getSwitchSkillState(skel.name) == fk.SwitchYang then
        return data.card.color == Card.Black
      else
        return data.card.color == Card.Red
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local isYang = player:getSwitchSkillState(skel.name, true) == fk.SwitchYang
    if isYang then
      room:loseHp(player, 1, skel.name)
    else
      room:changeMaxHp(player, -1)
    end
    if player.dead then return end
    local suits = isYang and "diamond,heart" or "spade,club"
    local ids = room:getCardsFromPileByRule(".|.|"..suits, 2)
    if #ids > 0 then
      room:obtainCard(player, ids, false, fk.ReasonJustMove, player, skel.name)
    end
  end,
})

return skel
